package com.tobias.gaokao.util;

import java.time.LocalDate;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.util.StringUtils;
import java.util.Random;

public class CommonUtils {

	private final static int DAY = 0;
	private final static int MONTH = 1;
	private final static int YEAR = 2;

	public static LocalDate changeToDate(String dateField) {
		String[] number = dateField.split("\\.");
		return LocalDate.of(Integer.parseInt(number[YEAR]), Integer.parseInt(number[MONTH]),
				Integer.parseInt(number[DAY]));
	}

	public static boolean withinLastThreeMonth(LocalDate dateField) {
		return LocalDate.now().minusMonths(3).isAfter(dateField) ? false : true;
	}

	public static boolean isDateFormat(String str) {
		if (StringUtils.isEmpty(str)) {
			return true;
		}
		String format = "\\d{2}.\\d{2}.\\d{4}";
		Pattern p = Pattern.compile(format);
		Matcher m = p.matcher(str);
		if (m.matches()) {
			return true;
		}
		return false;
	}

	public static boolean isAmount(String str) {
		if (StringUtils.isEmpty(str)) {
			return true;
		}
		String reg = "^[0-9000]+(.[0-9999]+)?$";
		return str.matches(reg);
	}

	public static int getRandomNumber(int n) {
		Random random = new Random();
		return random.nextInt(n);
	}

	public static int getRandomNumber(int n, int m) {
		Random random = new Random();
		int range = random.nextInt(m-n);
		return n + range;
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int min = scanner.nextInt();
		int max = scanner.nextInt();
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
		System.out.println(getRandomNumber(min, max));
	}

}
